#include <iostream>

using namespace std;

int main()
{
    string comet, troop;
    cin >> comet >> troop;
    int c = 1; int t = 1;
    for (unsigned int i=0; i<comet.size(); ++i)
    {
        c *= (comet[i]-64);
    }
    for (unsigned int i=0; i<troop.size(); ++i)
    {
        t *= (troop[i] - 64);
    }
    if (c%47 == t%47) cout << "GO";
    else cout << "STAY";
    return 0;
}
